home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Languguage OS 2
/
Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO
/
a_utils
/
perl
/
prlbkxmp.lha
/
ch6
/
nfinger
< prev
next >
Wrap
Text File
|
1991-01-08
|
1KB
|
68 lines
#!/usr/bin/perl
# Usage: finger [fingeroptions] [names]
# Bind %ALIAS to the aliases database.
dbmopen(ALIAS,'/usr/lib/aliases',undef)
|| die "can't dbmopen aliases";
# Strip finger switches.
while ($ARGV[0] =~ /^-/) {
push(@fingerargs, shift);
}
# Process user names.
while ($user = shift) {
push(@finger, &resolve($user));
}
# Uniquify names.
@finger = grep(!$seen{$_}++, @finger);
# And run finger.
exec 'finger', @fingerargs, @finger if @finger;
die "Couldn't run finger: $!\n";
##############################################################
sub resolve {
local($home,$addr,$alias,@list);
while ($addr = shift) {
if (defined $ALIAS{$addr."\0"}) { # In dbm file.
chop($alias = $ALIAS{$addr."\0"});
}
else {
$home = (getpwnam($addr))[7];
if (defined($home) && -r "$home/.forward") {
open(FORWARD,"$home/.forward");
chop($alias = <FORWARD>);
close FORWARD;
}
else {
push(@list, $addr); # Not aliased.
next;
}
}
$alias =~ s/"\|[^"]*",?//g;
$alias =~ s/^\s*(.*)\s*$/$1/;
if ($alias eq '') { # Oops, only pipes.
push(@list, $addr); # So back out alias.
next;
}
$alias =~ s/([^!]*)!(.*)/$2@$1/; # A uucp addr?
# Now call ourselves recursively.
push(@list,&resolve(split(/[\s,]+/,$alias)));
}
return @list;
}